<script>
$(document).ready(function() {
    //prepare the dialog
	
    $( "#succ" ).dialog({
		title: "Thông báo",
        autoOpen: false,
        show: {
            effect: "blind",
            duration: 500
            },
        hide: {
            effect: "blind",
            duration: 500
            },
        modal: true,
		buttons: {
			 "Ok": function() {
				location.reload();
				 $('#succ').dialog('close');
			}
		 }
        });
		
	
	$(".close_importservice").click(function(event) {
				$('#dialogModal').dialog('close');
			});
    });

	var specialKeys = new Array();
	specialKeys.push(8); //Backspace
	function IsNumeric(e) {
		var keyCode = e.which ? e.which : e.keyCode
		var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
		document.getElementById("error").style.display = ret ? "none" : "inline";
		return ret;
	}
</script>
<p style="margin-top:10px;font-weight: bold;"> Bảng số liệu nhập gần đây</p>
<div class="cate-infor" style="border:none !important; margin-top:20px;">
<div class="block-content">
<table cellspacing="0" cellpadding="0" width="100%" class="dv">
		<tr>
			<th style="text-align: center; width: 4%;">STT</th>
			<th style="text-align: center; width: 15%;">Số lượng</th>
			<th style="text-align: center; width: 20%;">Đơn giá</th>
			<th style="text-align: center; width: 20%;">Ghi chú</th>
			<th style="text-align: center; width: 23%;">Thời gian</th>
			<th style="text-align: center; width: 18%;" style="border-right:1px solid #c0c0c0;">Nhân viên</th>		
		</tr>
		<?php $i = 0;?>
		<?php foreach($ser as $import){ $i++; ?>
		<tr>
		<td style="padding-left: 6px"><?php echo $i;?></td>
		<td style="padding-left: 6px"><?php echo $import['ImportService']['count'];?></td>
		<td style="padding-left: 6px">
		
			<?php 
				$dongia = 	$import['ImportService']['price']/$import['ImportService']['count'];
				echo round($dongia,2)." VNĐ";
			?>			
		</td>
		<td style="padding-left: 6px"><?php echo $import['ImportService']['note'];?></td>
		<td style="padding-left: 6px"><?php echo $import['ImportService']['time'];?></td>
		<td style="border-right:1px solid #c0c0c0;padding-left: 6px">Trang</td>
		</tr>
		<?php }?>
	</table>
</div>
</div>
<?php echo $this->Form->create('ImportService'); ?>
<input type="hidden" name = "data[ImportService][services_id]" value = "<?php echo $id;?>" />
<input type="hidden" name = "data[ImportService][time]" value = "<?php echo date("Y-m-d H:i:s");?>" />
<?php //debug($this->request->data);?>
<table width="100%">
<tr>
	<td>
		<div class="row">
			<label>Ghi chú</label>
		</div>
	</td>
	<td>
		<div class="row">
			<label>Số lượng</label>
		</div>
	</td>
	<td>
		<div class="row">
			<label>Tổng tiền(VNĐ)</label>
		</div>
	</td>
</tr>
<tr>
	<td>
		<div class="row">
			<?php echo $this->Form->input('note',array('label'=>false, 'style'=>'width:256px;','div'=>false));?>
		</div>
	</td>
	<td>
		<div class="row">
			<?php echo $this->Form->input('count',array('label'=>false,'type'=>'text' ,'id'=>'text1','style'=>'max-width:256px;','div'=>false,'onkeypress'=>'return IsNumeric(event);','onpaste'=>'return false;','ondrop'=>'return false;'));?>
			<span id="error" style="color: Red; display: none">* Chỉ nhập số</span>
		</div>
	</td>
	<td>
		<div class="row">
			<?php echo $this->Form->input('price',array('label'=>false,'type'=>'text', 'style'=>'max-width:256px;','div'=>false,'id'=>'demo1'));?>
			<script type="text/javascript">$("#demo1").maskMoney();</script>
		</div>
	</td>
</tr>
</table>
<div class="btn-dialog">
	<?php 
	echo $this->Js->submit('Ok', array(  //create 'ajax' save button
		'update' => '#contentWrap','div'=>false  //id of DOM element to update with selector
		));
	if (true== $saved){ //will only be true if saved OK in controller from ajax save above
		echo "<script>
			$('#succ').dialog('open');  
		</script>";
		}
	echo $this->Form->end();
	echo $this->Js->writeBuffer();
	?>
	<input type="button" value="Cancel" class="close_importservice">
</div>

<div id="succ" title="Thông báo">
<p align="center">Đã nhập dịch vụ thành công thành công</p>
</div>

<?php //echo date("d-m-Y H:i");?>